package com.example.gulimallcart.controller;

import com.example.common.utils.PageUtils;
import com.example.gulimallcart.interceptor.CartInterceptor;
import com.example.gulimallcart.service.CartService;
import com.example.gulimallcart.vo.CartItem;
import com.example.gulimallcart.vo.UserInfoTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpSession;

@Controller
public class CartController {
    @Autowired
    CartService cartService;
    @GetMapping("/cart.html")
    public String cartListPage(){
        UserInfoTo userInfoTo = CartInterceptor.threadLocal.get();
        System.out.println(userInfoTo);
        return "cartList";
    }

    @GetMapping("/addToCart")
    public String addToCart(@RequestParam("skuId") Long skuId,
                            @RequestParam("num") Integer num,
                            Model model){
        //把商品添加进购物车
        //CartItem cartItem = cartService.addToCart(skuId,num);
        //model.addAttribute("item",cartItem);
        return "success";
    }
}
